﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using RTSoft.Modules;
using System.Data.SqlClient;

namespace RTSoft.SoureCode.Control.City
{
    class cityctrl
    {
        DataProvider provider = new DataProvider();
        SqlCommand cmd = new SqlCommand();
        String strSQL = "";

        public void getDataByID(ref String errConnect, ref String errSQL, ref DataTable tbl,int id)
        {
            provider.Connection(ref errConnect);
            try
            {
                tbl = new DataTable();
                strSQL = "select locationId,locationName,parentId from CITY where parentId = "+id;
                tbl = provider.LayDanhSach(strSQL);
            }
            catch (Exception ex)
            {
                errSQL = ex.Message;
            }
            finally
            {
                provider.Disconnect();
            }
        }

        public void getData(ref String errConnect, ref String errSQL, ref DataTable tbl)
        {
            provider.Connection(ref errConnect);
            try
            {
                tbl = new DataTable();
                strSQL = "select locationId,locationName,parentId from CITY where parentId = 21 ";
                tbl = provider.LayDanhSach(strSQL);
            }
            catch (Exception ex)
            {
                errSQL = ex.Message;
            }
            finally
            {
                provider.Disconnect();
            }
        }		
    }
}
